#include "Frame.h"
#include "Strategy.h"
#include "Snake.h"
#include "Log.h"
#include "Net.h"
#include "ClientPlatform.h"

#include "cs_login.pb.h"

#include <stdlib.h>
#include <time.h>
#ifdef _WIN32
#include <windows.h>
#else
#endif

class CNetServerTest : public CNet
{

public:
    CNetServerTest() :m_iRecvStep(1) {}
    ~CNetServerTest() {}
public:
    virtual bool OnPacket(const int iSocket, char *pData, int iLen)
    {
        char csBuff[1024];
        switch (m_iRecvStep)
        {
        case 1:
            cs::LoginReq csLoginReq;
            csLoginReq.ParseFromArray(pData, iLen);
            LOG_DBG("Server Recv:%s", csLoginReq.DebugString().c_str());

            cs::LoginRes csLoginRes;
            csLoginRes.set_welcomemessage("welcome to lost world");
            csLoginRes.SerializeToArray(csBuff, sizeof(csBuff));
            Send(iSocket, csBuff, csLoginRes.ByteSize());
            LOG_DBG("Server Send:%s", csLoginRes.DebugString().c_str());
            break;
        }
        ++m_iRecvStep;
        return CNet::OnPacket(iSocket, pData, iLen);
    }
private:
    int m_iRecvStep;
};


int main(void)
{

    CClientPlatform::Instance().Init();
    CClientPlatform::Instance().Run(0, NULL);

    return 0;
}
